package com.lucweb.service.impl;


import com.lucweb.dao.BaseDictDao;
import com.lucweb.dao.CompanyDao;
import com.lucweb.entity.BaseDict;
import com.lucweb.entity.TaskCompany;
import com.lucweb.service.CompanyService;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

@Service("companyService")
public class CompanyServiceImpl implements CompanyService {
    @Resource
    private CompanyDao companyDao;

    @Resource
    private BaseDictDao baseDictDao;




    @Override
    public String newcompanyTask() {

        return null;
    }

    @Override
    public void saveCompany(TaskCompany taskcompany) {
        companyDao.saveOrUpdate(taskcompany);


        BaseDict baseDict = new BaseDict();

        baseDict.setDict_id(UUID.randomUUID().toString());
        baseDict.setDict_type_code("2");
        baseDict.setDict_item_name(taskcompany.getCompanyName());
        baseDict.setDict_item_code(taskcompany.getId()+"");
        baseDict.setDict_type_name("单位名称");

        baseDictDao.save(baseDict);




    }

    @Override
    public void saveOrUpdate(TaskCompany taskcompany) {
        companyDao.saveOrUpdate(taskcompany);




    }

    @Override
    public TaskCompany gettaskcompanyById(int taskId) {
        return this.companyDao.getcompanyById(taskId);
    }

    @Override
    public List<TaskCompany> gettaskcompanyByName(String para) {
        return this.companyDao.companyList(para);
    }

    @Override
    public boolean deletecompanytask(int taskId) {
        companyDao.deletecompany(taskId);
        return true;
    }

    @Override
    public List<TaskCompany> showcompany() {
        return this.companyDao.showcompany();
    }

    @Override
    public int getmaxId() {
        return this.companyDao.getmaxId();
    }


}
